home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume2 / conquest / part05 < prev   
Encoding:
Internet Message Format  |  1987-10-26  |  43.0 KB

  1. Path: uunet!tektronix!tekgen!tekred!games-request
  2. From: games-request@tekred.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v02i062:  conquest - middle earth multi-player game, Part05/05
  5. Message-ID: <1745@tekred.TEK.COM>
  6. Date: 26 Oct 87 19:30:23 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 1417
  9. Approved: billr@tekred.TEK.COM
  10.  
  11. Submitted by: ihnp4!mhuxd!smile (E.BARLOW)
  12. Comp.sources.games: Volume 2, Issue 62
  13. Archive-name: conquest/Part05
  14.  
  15.  
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 5 (of 5)."
  24. # Contents:  .nations DIST-NOTE forms.c header.h io.c
  25. # Wrapped by billr@tekred on Mon Oct 26 10:33:09 1987
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f .nations -a "${1}" != "-c" ; then 
  28.   echo shar: Will not over-write existing file \".nations\"
  29. else
  30. echo shar: Extracting \".nations\" \(2950 characters\)
  31. sed "s/^X//" >.nations <<'END_OF_.nations'
  32. X# GAME MASTERS FILE ON NPC NATIONS:  COMPILE TIME ONLY
  33. X#  comments are offset by a # sign in the first column
  34. X#
  35. X#  THERE IS A LIMIT OF "MAXNTN" NATIONS TOTAL; Be sure this is ok
  36. X#
  37. X# name         :nations name
  38. X#        :examples include Darboth Ummaya Rugar Jute Atlantis Iberia 
  39. X#        :Kuybyshev Avar Grodor Bantanya Fung Codor Delph Macitania 
  40. X# leader     : permitted leaders are "dwarfking","elfking","elfdruid",
  41. X#            "elfwizard","demon","dragon","wizard","priest",
  42. X#            "shadow","king","priestking","wizard","demigod"
  43. X# race       :Character, ORC='O',ELF='E',DWARF='D',LZARD='L',HUMAN='H'
  44. X#        :BRIGAND='P' BARBARIAN='B'
  45. X# mark        :unique mark for race (ie & or ! or 1 or H...)
  46. X# loc         :G,F,R  location (good,fair,random)
  47. X# aplus     :attack percentage plus (multiples of 10 (ie 10,20,30))
  48. X# dplus        :defence percentage plus (multiples of 10 (ie 10,20,30))
  49. X# maxmove     :movement rate (4 to 8)
  50. X# gold        :total gold at start
  51. X# mil         :total military at start
  52. X# civilians     :total civilians at start
  53. X# repro-rate    :reproduction rate of nation (percentage)
  54. X# aggr        :aggressiveness (1--always peaceful) to (10 -- always hostile)
  55. X#
  56. X#EXAMPLE NATIONS                            PTS
  57. X#    Sporf    demon      O S R 0  0   6  1000  2500 4000 10 9     9
  58. X#    Athens   king       H A R 10 10  9  10000 500  5000 5 4        9
  59. X#    Fung     king       E F F 20 30  8  20000 200  3000 3 2        6
  60. X#    X        dwarfking  D X R 20 20  6  20000 1500 4000 4 4     6
  61. X#    ADD PTS IN VALUE TO THE ABOVE FORE RACIAL BASES TO GET BALANCE
  62. X#
  63. X#  THE NATIONS LISTED BELOW ARE CALIBRATED AS FOLLOWS
  64. X#  ELVES: fung (27), lint (28), anorian (29), roos (22)       =>106 points
  65. X#  ORCS : sporf (24), etland (24), woolos (36), darboth (20)       =>106 points
  66. X#  HUMAN: argos(24), taelos(20), cordoba(21), zaos(21), tokus(20) =>106
  67. X#  DWARF: Goldor (22), Muldor (38), Sodor (25)points, Valar(20)     =>106 points
  68. X#
  69. X# format:     (note that offset by a space)
  70. X#
  71. X# name leader race mark location aplus dplus maxmove gold mil civ repro aggr
  72. X#########################################################################
  73. Xanorian  elfwizard  E A F 30 40  8  30000 1500 8500 8 2
  74. Xargos    king       H a R 10 10  9  10000 1500 11000 7 4
  75. Xbobland  dragon     O b F 20 0   6  1000  1500 8000 10 9
  76. Xcordoba  wizard     H c R 10 10  2  10000 1500 8000 8 4
  77. Xdarboth  balrog     O d R 0  0   7  30000 1500 9500 8  9
  78. Xedland   dragon     O e R 20 0   8  1000  1500 8500 10 9
  79. Xfarmland warking    H F R 10 10  9  20000 1000 6150 8 4
  80. Xfung     elfking    E f F 10 40  8  20000 1000 9500 8 2
  81. Xgelos    dwarfduke  D g F 15 10  9  20000 1000 7900 7 8
  82. Xlint     elfwizard  E l F 20 30  8  20000 1500 7900 10 2
  83. XMuldor   dwarfking  D m F 10 30  6  60000 5000 18000 7 4
  84. Xmoria    dwarfduke  D M R 10 30  6  20000 1000 10000 8 4
  85. Xroos     elfpriest  E r R 20 0   6  3000  2000 6500 10 9
  86. Xtokus    king       H T R 10 10  8  10000 1000 7500 8 4
  87. Xwoolos   shadow     O w F 10 10  10 10000 3500 17000 10 9
  88. XValar    dwarf      D v R 10 15  8  10000 1000 7000 8 4
  89. Xzaos     king       H z R 10 15  12 10000 1000 7000 8 4
  90. END_OF_.nations
  91. if test 2950 -ne `wc -c <.nations`; then
  92.     echo shar: \".nations\" unpacked with wrong size!
  93. fi
  94. # end of overwriting check
  95. fi
  96. if test -f DIST-NOTE -a "${1}" != "-c" ; then 
  97.   echo shar: Will not over-write existing file \"DIST-NOTE\"
  98. else
  99. echo shar: Extracting \"DIST-NOTE\" \(446 characters\)
  100. sed "s/^X//" >DIST-NOTE <<'END_OF_DIST-NOTE'
  101. X                        October 26, 1987
  102. X
  103. X
  104. XBill Randle
  105. XModerator
  106. Xcomp.sources.games
  107. X
  108. XBill,
  109. X
  110. XThe reason I want to limit re-distribution is to assure source code
  111. Xintegrity when I get modification requests...  This version has been
  112. Xplayed by myself about a dozen times, but there will still be many
  113. Xmany bugs and changes... I do want as wide a distribution as possible,
  114. Xso, you have permission to distribute this as widely
  115. Xas desired.  
  116. X
  117. XThanks!
  118. XEd
  119. Xihnp4!mhuxd!smile
  120. END_OF_DIST-NOTE
  121. if test 446 -ne `wc -c <DIST-NOTE`; then
  122.     echo shar: \"DIST-NOTE\" unpacked with wrong size!
  123. fi
  124. # end of overwriting check
  125. fi
  126. if test -f forms.c -a "${1}" != "-c" ; then 
  127.   echo shar: Will not over-write existing file \"forms.c\"
  128. else
  129. echo shar: Extracting \"forms.c\" \(12808 characters\)
  130. sed "s/^X//" >forms.c <<'END_OF_forms.c'
  131. X/*conquest is copyrighted 1986 by Ed Barlow.
  132. X *  I spent a long time writing this code & I hope that you respect this.  
  133. X *  I give permission to alter the code, but not to copy or redistribute
  134. X *  it without my explicit permission.  If you alter the code, 
  135. X *  please document changes and send me a copy, so all can have it.  
  136. X *  This code, to the best of my knowledge works well,  but it is my first
  137. X *  'C' program and should be treated as such.  I disclaim any
  138. X *  responsibility for the codes actions (use at your own risk).  I guess
  139. X *  I am saying "Happy gaming", and am trying not to get sued in the process.
  140. X *                                                Ed
  141. X */
  142. X
  143. X
  144. X/*    screen subroutines    */
  145. X
  146. X/*include files*/
  147. X#include <ctype.h>
  148. X#include "header.h"
  149. X
  150. Xextern FILE *fexe;
  151. Xextern short country;
  152. X
  153. Xshowscore()
  154. X{
  155. X    int i;
  156. X    int done=0;
  157. X    int position;
  158. X    int count;        /*number of time through the loop on this screen*/
  159. X    int nationid;        /*current nation id */
  160. X
  161. X    nationid=1;
  162. X    while((done==0)&&(nationid<MAXNTN)) {
  163. X        clear();
  164. X        standout();
  165. X        mvaddstr(0,(COLS/2)-10,"NATION SCORE SCREEN");
  166. X        standend();
  167. X        mvaddstr(3,0,"nationid is:");
  168. X        mvaddstr(4,0,"name is:");
  169. X        mvaddstr(5,0,"leader:");
  170. X        mvaddstr(6,0,"race:");
  171. X        mvaddstr(7,0,"class:");
  172. X        mvaddstr(8,0,"score:");
  173. X        mvaddstr(9,0,"gold:");
  174. X        mvaddstr(10,0,"military:");
  175. X        mvaddstr(11,0,"civilians:");
  176. X        mvaddstr(12,0,"sectors:");
  177. X        mvaddstr(13,0,"ships:");
  178. X
  179. X        count=0;
  180. X        position=2;
  181. X        while((nationid<MAXNTN)&&(count<5)){
  182. X            if((nationid<MAXNTN)&&(ntn[nationid].active!=0)) {
  183. X                position+=13;
  184. X                mvprintw(3,position,"%d",nationid);
  185. X                standout();
  186. X                mvprintw(4,position,"%s",ntn[nationid].name);
  187. X                standend();
  188. X                mvprintw(5,position,"%s",ntn[nationid].leader);
  189. X                for(i=1;i<8;i++)
  190. X                    if(ntn[nationid].race==*(races+i)[0])
  191. X                        mvprintw(6,position,"%s",*(races+i));
  192. X                if(ntn[nationid].active>=2) mvprintw(7,position,"NPC");
  193. X                else mvprintw(7,position,"%s",*(Class+ntn[nationid].class));
  194. X                mvprintw(8,position,"%d",ntn[nationid].score);
  195. X                mvprintw(9,position,"%d",ntn[nationid].tgold);
  196. X                mvprintw(10,position,"%d",ntn[nationid].tmil);
  197. X                mvprintw(11,position,"%d",ntn[nationid].tciv);
  198. X                mvprintw(12,position,"%d",ntn[nationid].tsctrs);
  199. X                mvprintw(13,position,"%d",ntn[nationid].tships);
  200. X                count++;
  201. X            }
  202. X            nationid++;
  203. X        }
  204. X        standout();
  205. X        mvaddstr(18,(COLS/2)-12,"HIT ANY KEY TO CONTINUE");
  206. X        mvaddstr(19,(COLS/2)-9,"HIT SPACE IF DONE");
  207. X        standend();
  208. X        refresh();
  209. X        if (getch()==' ') done=1;
  210. X    }
  211. X}
  212. X
  213. Xdiploscrn()
  214. X{
  215. X    int i;
  216. X    char k;
  217. X    short nation, offset, count, olddip, oldnat, temp;
  218. X    FILE *fp, *fopen();
  219. X    short isgod=0;
  220. X    if(country==0) {
  221. X        isgod=1;
  222. X        clear();
  223. X        mvaddstr(0,0,"WHAT NATION NUMBER:");
  224. X        refresh();
  225. X        echo();
  226. X        scanw("%hd",&country);
  227. X        noecho();
  228. X    }
  229. X    while(1){
  230. X        count=1;
  231. X        offset=0;
  232. X        clear();
  233. X        standout();
  234. X        mvaddstr(0,(COLS/2)-10,"NATION DIPLOMACY SUMMARY");
  235. X        standend();
  236. X        mvaddstr(2,0,"                BY YOU,        TO YOU");
  237. X        for(i=1;i<MAXNTN+4;i++) if((ntn[i].active>0)&&(i!=country)) {
  238. X            if(count%14==0) {
  239. X                offset+=40;
  240. X                mvaddstr(2,40,"                BY YOU,        TO YOU");
  241. X                count++;
  242. X            }
  243. X            mvprintw(count%14+2,offset, "%d. %s",i,ntn[i].name);
  244. X            mvprintw(count%14+2,offset+14, "=> %s",*(diploname+ntn[country].dstatus[i]));
  245. X            mvprintw(count%14+2,offset+28, "=> %s",*(diploname+ntn[i].dstatus[country]));
  246. X            count++;
  247. X        }
  248. X        standout();
  249. X        mvaddstr(17,0,"HIT RETURN KEY TO CHANGE STATUS");
  250. X        mvprintw(18,0,"HIT 'B' KEY TO BRIBE WARING NPC NATION (%d GOLD/level)",BRIBE);
  251. X        mvaddstr(19,0,"ANY OTHER KEY TO CONTINUE:");
  252. X        standend();
  253. X        refresh();
  254. X        k=getch();
  255. X        if((k!='\n')&&(k!='B')) {
  256. X            if(isgod==1) country=0;
  257. X            return;
  258. X        }
  259. X        if(k=='B'){
  260. X            if(ntn[country].tgold<=BRIBE){
  261. X                mvaddstr(21,0,"NOT ENOUGH GOLD");
  262. X                refresh();
  263. X                getch();
  264. X                return;
  265. X            }
  266. X            mvaddstr(20,0,"BRIBES WORK 50% (only the update will show)");
  267. X            mvaddstr(21,0,"WHAT NATION NUMBER:");
  268. X            refresh();
  269. X            echo();
  270. X            scanw("%hd",&nation);
  271. X            noecho();
  272. X            if(ntn[country].active>=2){
  273. X                mvaddstr(22,0,"NOT NON PLAYER COUNTRY");
  274. X                refresh();
  275. X                getch();
  276. X                return;
  277. X            }
  278. X            if((nation<=0)||(nation>MAXNTN)){
  279. X                if(isgod==1) country=0;
  280. X                return;
  281. X            }
  282. X            if((isgod!=1)&&((ntn[nation].dstatus[country]==ALLIED)||(ntn[nation].dstatus[country]==JIHAD)||(ntn[nation].dstatus[country]==CONFEDERACY))){
  283. X                mvaddstr(22,0,"CANT CHANGE THEIR STATUS");
  284. X                refresh();
  285. X                getch();
  286. X                return;
  287. X            }
  288. X            ntn[nation].dstatus[country]--;
  289. X            ntn[country].tgold-=BRIBE;
  290. X            ntn[nation].tgold+=BRIBE;
  291. X            EADJDIP;
  292. X            oldnat=country;
  293. X            country=nation;
  294. X            nation=oldnat;
  295. X            fprintf(fexe,"NGOLD\t%hd \t%d \t%d \t0 \t0 \t%s\n",XNAGOLD ,country,ntn[country].tgold,"null");
  296. X            EADJDIP;
  297. X            country=oldnat;
  298. X            return;
  299. X        }
  300. X        mvaddstr(21,0,"WHAT NATION NUMBER:");
  301. X        refresh();
  302. X        echo();
  303. X        scanw("%hd",&nation);
  304. X        if((nation<=0)||(nation>MAXNTN)){
  305. X            noecho();
  306. X            if(isgod==1) country=0;
  307. X            return;
  308. X        }
  309. X        noecho();
  310. X        if((isgod==0)&&(((ntn[country].dstatus[nation]==CONFEDERACY)&&(ntn[nation].dstatus[country]<WAR))||(ntn[country].dstatus[nation]==JIHAD))) {
  311. X            mvprintw(23,0,"SORRY, Can't change status on ntn %s -- hit return",ntn[nation].name);
  312. X            refresh();
  313. X            getch();
  314. X            return;
  315. X        }
  316. X        else{
  317. X            clear();
  318. X            mvaddstr(0,0,"WHAT NEW STATUS");
  319. X            mvaddstr(2,0,"1) CONFEDERACY (irrevocable)");
  320. X            mvaddstr(3,0,"2) ALLIED");
  321. X            mvaddstr(4,0,"3) FRIENDLY");
  322. X            mvaddstr(5,0,"4) NEUTRAL");
  323. X            mvaddstr(6,0,"5) HOSTILE");
  324. X            mvaddstr(7,0,"6) WAR");
  325. X            mvaddstr(8,0,"7) JIHAD (irrevocable):");
  326. X            mvaddstr(12,0,"INPUT:");
  327. X            refresh();
  328. X            scanw("%hd",&temp);
  329. X            if((temp<1)||(temp>7)){
  330. X                mvprintw(23,0,"SORRY, Invalid inputs -- hit return");
  331. X                refresh();
  332. X                getch();
  333. X                return;
  334. X            }
  335. X            ntn[country].dstatus[nation]=temp;
  336. X            EADJDIP;
  337. X
  338. X            /*prevent ron from being sneaky*/
  339. X            if((temp>HOSTILE)&&(ntn[nation].active>2)&&(ntn[nation].dstatus[country]<WAR)) {
  340. X                olddip=ntn[nation].dstatus[country];
  341. X                oldnat=country;
  342. X                country=nation;
  343. X                nation=oldnat;
  344. X                ntn[country].dstatus[nation]=WAR;
  345. X                EADJDIP;
  346. X                ntn[country].dstatus[nation]=olddip;
  347. X                oldnat=country;
  348. X                country=nation;
  349. X                nation=oldnat;
  350. X            }
  351. X            else if((temp>HOSTILE)&&(ntn[nation].active==1)&&(ntn[nation].dstatus[country]<WAR)) {
  352. X                if ((fp=fopen(MSGFILE,"a+"))==NULL) {
  353. X                    mvprintw(4,0,"error opening %s",MSGFILE);
  354. X                    refresh();
  355. X                    getch();
  356. X                    return;
  357. X                }
  358. X                fprintf(fp,"%s %s Declared war on you\n",ntn[nation].name,ntn[country].name);
  359. X                fputs("END\n",fp);
  360. X                fclose(fp);
  361. X            }
  362. X        }
  363. X    }
  364. X}
  365. X
  366. Xchange()
  367. X{
  368. X    char string[10];
  369. X    int i;
  370. X    short armynum;
  371. X    char passwd[8];
  372. X    short isgod=0;
  373. X
  374. X    if(country==0) {
  375. X        isgod=1;
  376. X        clear();
  377. X        mvaddstr(0,0,"SUPER USER; FOR WHAT NATION NUMBER:");
  378. X        refresh();
  379. X        echo();
  380. X        scanw("%hd",&country);
  381. X        noecho();
  382. X    }
  383. X    clear();
  384. X    mvaddstr(0,(COLS/2)-10,"NATION STATS SUMMARY");
  385. X    mvprintw(5,0,"1. nation name is %s   ",ntn[country].name);
  386. X    mvprintw(6,0,"2. password is XXXXXXXX");
  387. X    mvprintw(12,0,"capital loc: x is %d",ntn[country].capx);
  388. X    mvprintw(13,0,"             y is %d",ntn[country].capy);
  389. X    mvprintw(14,0,"leader is %s",ntn[country].leader);
  390. X    mvprintw(15,0,"class is %s",*(Class+ntn[country].class));
  391. X    mvprintw(16,0,"nations mark is...%c ",ntn[country].mark);
  392. X    for(i=1;i<8;i++) if(ntn[country].race==*(races+i)[0])
  393. X        mvprintw(17,0, "nation race is....%s  ",*(races+i));
  394. X    mvprintw(18,0,"score currently...%d",ntn[country].score);
  395. X
  396. X    mvprintw(4,(COLS/2), "attack bonus...........+%2d",ntn[country].aplus);
  397. X    mvprintw(5,(COLS/2), "defense bonus..........+%2d",ntn[country].dplus);
  398. X    mvprintw(6,(COLS/2), "maximum move rate.......%2d",ntn[country].maxmove);
  399. X    mvprintw(7,(COLS/2), "reproduction rate......%2d%%",ntn[country].repro);
  400. X    mvprintw(9,(COLS/2), "gold talons........$%5ld",ntn[country].tgold);
  401. X    mvprintw(10,(COLS/2),"jewels ............$%5ld",ntn[country].jewels);
  402. X    mvprintw(11,(COLS/2),"iron & minerals......%5ld",ntn[country].tiron);
  403. X    if(ntn[country].tfood<2*ntn[country].tciv) standout();
  404. X    mvprintw(12,(COLS/2),"food in granary......%5ld",ntn[country].tfood);
  405. X    standend();
  406. X
  407. X    mvprintw(13,(COLS/2),"total soldiers.......%5ld",ntn[country].tmil);
  408. X    mvprintw(14,(COLS/2),"total civilians......%5ld",ntn[country].tciv);
  409. X    mvprintw(15,(COLS/2),"total ships..........%5d",ntn[country].tships);
  410. X    mvprintw(16,(COLS/2),"total sectors........%5d",ntn[country].tsctrs);
  411. X
  412. X    standout();
  413. X    mvaddstr(19,(COLS/2)-9, "HIT ANY KEY TO CONTINUE");
  414. X    mvaddstr(20,(COLS/2)-15,"HIT 1 or 2 TO CHANGE NAME or PASSWD");
  415. X    mvaddstr(21,(COLS/2)-15,"HIT 3 TO CHANGE ADD TO COMBAT BONUS");
  416. X    if(isgod==1) mvaddstr(21,(COLS/2)-9,"HIT 4 TO DESTROY NATION");
  417. X
  418. X    standend();
  419. X    refresh();
  420. X    switch(getch()){
  421. X    case '1': /*get name*/
  422. X        clear();
  423. X        echo();
  424. X        mvaddstr(0,0,"what name would you like:");
  425. X        clrtoeol();
  426. X        refresh();
  427. X        scanw("%s",string);
  428. X        if((strlen(string)<=1)||(strlen(string)>=10)){
  429. X            beep();
  430. X            mvaddstr(2,0,"invalid name--hit return");
  431. X            noecho();
  432. X            refresh();
  433. X            getch();
  434. X            if(isgod==1) country=0;
  435. X            return;
  436. X        }
  437. X        /*check if already used*/
  438. X        else for(i=1;i<(country-1);i++){
  439. X            if((strcmp(ntn[i].name,string)==0)&&(i!=country)) {
  440. X                mvaddstr(2,0,"name already used--hit return");
  441. X                beep();
  442. X                noecho();
  443. X                refresh();
  444. X                getch();
  445. X                if(isgod==1) country=0;
  446. X                return;
  447. X            }
  448. X        }
  449. X        strcpy(ntn[country].name,string);
  450. X        noecho();
  451. X        ECHGNAME;
  452. X        break;
  453. X    case '2': /*change password */
  454. X        clear();
  455. X        if(isgod!=1){
  456. X            mvaddstr(0,0,"what is your current password:");
  457. X            refresh();
  458. X            scanw("%s",string);
  459. X            strcpy(passwd,crypt(string,SALT));
  460. X            if((strncmp(passwd,ntn[0].passwd,PASSLTH)!=0)&&(strncmp(passwd,ntn[country].passwd,PASSLTH)!=0)){
  461. X                beep();
  462. X                mvaddstr(2,0,"invalid password--hit return");
  463. X                refresh();
  464. X                getch();
  465. X                if(isgod==1) country=0;
  466. X                return;
  467. X            }
  468. X        }
  469. X        mvaddstr(2,0,"what is your new password:");
  470. X        refresh();
  471. X        scanw("%s",string);
  472. X        if((strlen(string)>8)||(strlen(string)<2)) {
  473. X            beep();
  474. X            mvaddstr(2,0,"invalid new password--hit return");
  475. X            refresh();
  476. X            getch();
  477. X            if(isgod==1) country=0;
  478. X            return;
  479. X        }
  480. X        mvaddstr(4,0,"reenter your new password:");
  481. X        refresh();
  482. X        scanw("%s",passwd);
  483. X        if(strcmp(passwd,string)!=0) {
  484. X            if(isgod==1) country=0;
  485. X            return;
  486. X        }
  487. X        ECHGPAS;
  488. X        strncpy(ntn[country].passwd,crypt(string,SALT),PASSLTH);
  489. X        break;
  490. X    case '3':
  491. X        for(armynum=0;armynum<MAXARM;armynum++) if(ASOLD>0) i+=ASOLD;
  492. X        if(i<1500) i=1500;
  493. X        mvprintw(0,0,"DO YOU WISH SPEND %d IRON ON ATTACK (enter y or n):",IRONORE*i);
  494. X        refresh();
  495. X        if(getch()=='y'){
  496. X            if(ntn[country].tiron>IRONORE*i){
  497. X                ntn[country].aplus+=1;
  498. X                I_APLUS;
  499. X                ntn[country].tiron-=IRONORE*i;
  500. X            }
  501. X        }
  502. X        mvprintw(0,0,"DO YOU WISH SPEND %d IRON ON DEFENSE (enter y or n):",IRONORE*i);
  503. X        refresh();
  504. X        if(getch()=='y'){
  505. X            if(ntn[country].tiron>IRONORE*i){
  506. X                ntn[country].dplus+=1;
  507. X                I_DPLUS;
  508. X                ntn[country].tiron-=IRONORE*i;
  509. X            }
  510. X        }
  511. X        break;
  512. X    case '4':
  513. X        if(isgod==1){
  514. X            clear();
  515. X            mvaddstr(0,0,"DO YOU WANT TO DESTROY THIS NATION (y or n)");
  516. X            refresh();
  517. X            if(getch()=='y') destroy();
  518. X        }
  519. X        break;
  520. X    default:
  521. X        if(isgod==1) country=0;
  522. X        return;
  523. X    }
  524. X    if(isgod==1) country=0;
  525. X}
  526. X
  527. Xhelp()
  528. X{
  529. X    int lineno;
  530. X    FILE *fp, *fopen();
  531. X    int done=0;
  532. X    char line[80];
  533. X
  534. X    /*open .help file*/
  535. X    if ((fp=fopen(HELPFILE,"r"))==NULL) {
  536. X        mvaddstr(0,0,"\nerror on read \n");
  537. X        refresh();
  538. X        getch();
  539. X        return;
  540. X    }
  541. X
  542. X    while(done==0){
  543. X        /*read in screen (until DONE statement)*/
  544. X        fgets(line,80,fp);
  545. X        if(strncmp(line,"DONE",4)==0) done=1;
  546. X        else {
  547. X            clear();
  548. X            lineno=0;
  549. X            while(strncmp(line,"END",3)!=0) {
  550. X                mvaddstr(lineno,0,line);
  551. X                lineno++;
  552. X                if(lineno>LINES-3) strcpy(line,"END");
  553. X                else fgets(line,80,fp);
  554. X            }
  555. X            standout();
  556. X            mvaddstr(LINES-2,(COLS/2)-14,"HIT SPACE TO CONTINUE HELP SCREENS");
  557. X            mvaddstr(LINES-1,(COLS/2)-12,"TO END HELP HIT ANY OTHER KEY");
  558. X            standend();
  559. X            refresh();
  560. X            if(getch()!=' ') done=1;
  561. X        }
  562. X    }
  563. X    fclose(fp);
  564. X}
  565. X
  566. Xnewspaper()
  567. X{
  568. X    int lineno;
  569. X    FILE *fp, *fopen();
  570. X    int newpage,done;
  571. X    short pagenum=1;
  572. X    char line[80];
  573. X    char title[80];
  574. X
  575. X    clear();
  576. X    if ((fp=fopen(NEWSFILE,"r"))==NULL) {
  577. X        mvaddstr(0,0,"error on read ");
  578. X        refresh();
  579. X        getch();
  580. X        return;
  581. X    }
  582. X
  583. X    /*open and read one page */
  584. X    done=0;
  585. X    newpage=0;
  586. X    if(fgets(title,80,fp)==NULL) done=1;
  587. X    while(done==0){
  588. X        if(newpage==0){
  589. X            clear();
  590. X            lineno=5;
  591. X            newpage=1;
  592. X            standout();
  593. X            mvprintw(0,20,"CONQUEST NEWS REPORT   page %d",pagenum);
  594. X            mvaddstr(1,23,"ALL THE NEWS THAT FITS");
  595. X            mvprintw(3,20,"%s",title+2);
  596. X            standend();
  597. X        }
  598. X
  599. X        if(fgets(line,80,fp)==NULL) done=1;
  600. X        else {
  601. X            if(line[1]!='.') {
  602. X                strcpy(title,line);
  603. X                newpage=0;
  604. X                pagenum++;
  605. X            }
  606. X            else {
  607. X                mvaddstr(lineno++,0,line+2);
  608. X                if(todigit(line[0])!=pagenum) {
  609. X                    newpage=0;
  610. X                    pagenum=todigit(line[0]);
  611. X                }
  612. X                else if(lineno>LINES-3) newpage=0;
  613. X            }
  614. X        }
  615. X
  616. X        if(newpage==0||done==1){
  617. X            standout();
  618. X            mvaddstr(LINES-2,(COLS/2)-13,"HIT ANY KEY TO CONTINUE");
  619. X            mvaddstr(LINES-1,(COLS/2)-12,"TO END NEWS HIT SPACE");
  620. X            standend();
  621. X            refresh();
  622. X            if(getch()==' ') done=1;
  623. X        }
  624. X    }
  625. X    fclose(fp);
  626. X}
  627. END_OF_forms.c
  628. if test 12808 -ne `wc -c <forms.c`; then
  629.     echo shar: \"forms.c\" unpacked with wrong size!
  630. fi
  631. # end of overwriting check
  632. fi
  633. if test -f header.h -a "${1}" != "-c" ; then 
  634.   echo shar: Will not over-write existing file \"header.h\"
  635. else
  636. echo shar: Extracting \"header.h\" \(12852 characters\)
  637. sed "s/^X//" >header.h <<'END_OF_header.h'
  638. X/*conquest is copyrighted 1986 by Ed Barlow.*/
  639. X/*  MODIFICATION OF THIS FILE IMPLIES THAT THE MODIFIER WILL ACCEPT
  640. X     A LIMITED USE COPYRIGHT AS FOLLOWS:
  641. X
  642. X        1) This software is copyrighted and protected by law.  The
  643. X        sole owner of this software, which hereafter is known as
  644. X        "conquest" is Edward M. Barlow, who hereby grants you a 
  645. X        personal, non-exclusive right to use this software.
  646. X         2) conquest may not be redistributed in any form.  Any
  647. X        requests for new software shall, for now, be the perogative
  648. X        of the author.
  649. X         3) loss or damage caused by this software shall not be
  650. X        the responsibility of the author.
  651. X        4) Ed Barlow shall be notified of modifications to this 
  652. X        software via electronic mail (mhuxd!smile) and, if there
  653. X        is no response, via US mail to:
  654. X
  655. X            Ed Barlow
  656. X            974 Delchester Rd
  657. X            Newtown Sq. PA, 19073
  658. X
  659. X        5) you agree to use your best efforts to see that any user
  660. X        of conquest complies with the terms and conditions stated above.
  661. X*/
  662. X
  663. X/*MODIFICATION IS REQUIRED OF THE FOLLOWING DEFINE STATEMENTS*/
  664. X
  665. X/*file name definitions */
  666. X#define EXEFILE        "/c03/smile/private/mygame/lib/.execute"
  667. X#define DATAFILE     "/c03/smile/private/mygame/lib/.data"
  668. X#define MSGFILE        "/c03/smile/private/mygame/lib/.messages"
  669. X#define NPCSFILE     "/c03/smile/private/mygame/lib/.nations"
  670. X#define HELPFILE     "/c03/smile/private/mygame/lib/.help"
  671. X#define NEWSFILE     "/c03/smile/private/mygame/lib/.news"
  672. X
  673. X#define OWNER    "Ed Barlow"    /*administrators name*/
  674. X
  675. X/*MODIFICATION IS OPTIONAL ON THE FOLLOWING*/
  676. X#define PWATER 55     /*percentage of water in the world*/
  677. X
  678. X#define MAPX 48        /*Number of X Sectors on Map (divisible by 8 prefered)*/
  679. X                        /*  if you change see MAXX and MAXY*/
  680. X#define MAPY 48        /*Number of Y Sectors on Map (divisible by 8 prefered)*/
  681. X                        /*  if you change see MAXX and MAXY*/
  682. X/*the below three variables *must* be based on the above two*/
  683. X/*MAXX=MAPX/8, MAXY=MAPY/8, NUMAREAS=MAXX*MAXY*/
  684. X#define MAXX 6         /*Number of X areas on map*/
  685. X#define MAXY 6            /*Number of Y areas on map*/ 
  686. X#define NUMAREAS 36       /*total # areas, MAXX*MAXY*/
  687. X
  688. X/*ALL THESE MUST BE COMMENTED OUT IF YOU WANT TO EXCLUDE THE C CODE*/
  689. X#define LZARD 1        /*defined if lizard npc's exist at beginning*/
  690. X#define MONSTER 1    /*defined if pirates/barbarians/nomads exist*/
  691. X#define NPC 1        /*defined if non player country exists at beginning*/
  692. X#define CMOVE 1        /*Comment this line out if you do not wish the computer
  693. X              to move Player nations if they forget to move*/
  694. X#define SYS5    1    /*comment this line out if on a BSD system*/
  695. X            /*--not that it does anything at the moment*/
  696. X
  697. X#define MAXNTN 28    /*number of nations (including unowned & npc ntns)*/
  698. X            /*but not including pirates...*/
  699. X#define NTOTAL        32 /*MAXNTN+4*/
  700. X#define NLIZARD        28 /*MAXNTN+0*/
  701. X#define NNOMAD        29 /*MAXNTN+1*/
  702. X#define NBARBARIAN     30 /*MAXNTN+2*/
  703. X#define NPIRATE        31 /*MAXNTN+3*/
  704. X
  705. X#define LANDSEE 2    /*how far you can see on land, by armies, by navies*/
  706. X#define NAVYSEE 1    /*making these numbers large takes CPU time*/
  707. X#define ARMYSEE 2
  708. X
  709. X/*Below taxation rates are in thousand dollars (US 1985) per 100 humans per 
  710. X *point of whatever -- ie 1 person in veg of 9 means produce $70x9=630K
  711. X *thousand dollars */
  712. X
  713. X#define TAXDEFAULT    5555    /*percent taxes*/
  714. X#define TAXFOOD        100
  715. X#define TAXIRON        100
  716. X#define TAXGOLD        100
  717. X/*city and capital tax rates based on people only (no multipleier)*/
  718. X#define TAXCAP        1000
  719. X#define TAXCITY        750
  720. X
  721. X#define SHIPMAINT     1000    /*ship mainatinance cost*/
  722. X#define SOLDMAINT     40    /*soldier mainatinance cost*/
  723. X
  724. X#define DESCOST        300    /*cost to redesignatie*/
  725. X                /*this is also the iron cost for cities*/
  726. X#define FORTCOST    1000    /*cost to build a fort point*/
  727. X#define ENLISTCOST     90    /*cost to enlist one troop*/
  728. X#define WARSHPCOST     3000    /*cost to build one warship*/
  729. X#define MERSHPCOST     2000    /*cost to build one merchant*/
  730. X
  731. X#define SHIPHOLD      300    /*number of humans a ship can hold*/
  732. X
  733. X#define MAXPTS        30     /*points to buy stuff with*/
  734. X#define SECTSCORE     1    /*SECTSCORE points per sector*/
  735. X#define CITYLIMIT     8    /*% of ntns people in sector before => city*/
  736. X
  737. X#define MAXARM         32    /*maximum number of armies per nation*/
  738. X#define MAXNAVY        16    /*maximum number of fleets per nation*/
  739. X#define MILRATIO     5    /*ratio mil:civ for non player countries*/
  740. X#define MILINCAP      5    /*ratio (mil in cap):mil for NPCs*/
  741. X
  742. X#define JWL_MGK        100000L    /*jewels needed to use magic*/
  743. X#define BRIBE        100000L    /*amount of gold to bribe one level*/
  744. X#define IRONORE        7    /*iron per soldier needed for +1% weapons%/
  745. X
  746. X
  747. X/*-----------------DO NOT ALTER BELOW THIS LINE-------------------*/
  748. X
  749. X#include <curses.h>
  750. X#define VERSION 1     /*version number of the game*/
  751. X#define FLAT 1        /*1 if world is flat 0 if round*/
  752. X
  753. X/*simple contour map definitions*/
  754. X#define WATER     '~'
  755. X#define PEAK     '#'    
  756. X#define MOUNTAIN '^'
  757. X#define HILL     '%'    
  758. X#define CLEAR     '-'
  759. X
  760. X/*racial types*/
  761. X#define GOD     '-'
  762. X#define ORC     'O'
  763. X#define ELF     'E'
  764. X#define DWARF     'D'
  765. X#define LIZARD     'L'
  766. X#define HUMAN     'H'
  767. X#define PIRATE  'P'
  768. X#define BARBARIAN 'B'
  769. X#define NOMAD      'N'
  770. X#define UNKNOWN '?'
  771. X
  772. X/*designations*/
  773. X#define DCITY        'c'
  774. X#define DCAPITOL    'C'
  775. X#define DMINE        'm'
  776. X#define DFARM        'f'
  777. X#define DDEVASTATED    'x'
  778. X#define DGOLDMINE    '$'
  779. X#define DCASTLE        '!'
  780. X#define DNODESIG    '-'
  781. X
  782. X#define GREAT    'G'
  783. X#define FAIR    'F'
  784. X#define RANDOM    'R'
  785. X#define OOPS    'X'
  786. X
  787. X/*vegitation types --  these are legal in designations too*/
  788. X#define VOLCANO 'V'
  789. X#define DESERT     'D'
  790. X#define WASTE      'W'
  791. X#define BARREN     '4'
  792. X#define LT_VEG     '6'    
  793. X#define GOOD     '9'
  794. X#define WOOD     '7'
  795. X#define FORREST '3'
  796. X#define JUNGLE     'J'    
  797. X#define SWAMP     'S'
  798. X#define ICE     'I'    
  799. X#define NONE     '~'
  800. X
  801. X/*Diplomacy Variables*/
  802. X#define JIHAD         7
  803. X#define WAR         6
  804. X#define HOSTILE        5
  805. X#define NEUTRAL        4
  806. X#define FRIENDLY    3
  807. X#define ALLIED         2
  808. X#define CONFEDERACY     1
  809. X#define UNMET        0
  810. X
  811. X/*army status*/
  812. X# define MARCH         1    /*March */
  813. X# define SCOUT        2    /*Scouting--will not engage enemy if possible*/
  814. X# define ATTACK     3    /*Attack anybody (Hostile+) within 2 sectors*/
  815. X# define DEFEND        4    /*Defend */
  816. X# define GARRISON     5    /*Garrison--for a city or Capital*/
  817. X
  818. X
  819. Xstruct s_sector
  820. X{
  821. X    char  designation;/*designation of sector*/
  822. X    char  altitude;  /*sector altitude */
  823. X    char  vegitation; /*sector vegitation  */
  824. X    short owner;      /*nation id of owner, MAXNTN+? is SPECIAL*/
  825. X    int   people;     /*civilians in sector*/
  826. X    short gold;      /*gold production ability*/
  827. X    short fortress;   /*fortification level (0 to 9)*/
  828. X    short iron;      /*amount of iron produced by sector*/
  829. X};
  830. X#define XREAL     xcurs+xoffset
  831. X#define YREAL     ycurs+yoffset
  832. X#define SOWN     sct[xcurs+xoffset][ycurs+yoffset].owner
  833. X
  834. Xstruct navy
  835. X{
  836. X    short warships;
  837. X    short merchant;
  838. X    short xloc;
  839. X    short yloc;
  840. X    short smove;
  841. X};
  842. X
  843. Xstruct army
  844. X{
  845. X    short xloc;
  846. X    short yloc;
  847. X    short smove;
  848. X    short sold; 
  849. X    short stat;
  850. X};
  851. X
  852. Xstruct     nation    /* player nation stats */
  853. X        {
  854. X        char   name[10];/* name */
  855. X        char   passwd[8];/* password */
  856. X        char   leader[10];/* leader title */
  857. X        char   race;    /* national race (integer--see header.h)*/
  858. X        short  class;    /* national class*/
  859. X/*location could be easily changed out*/
  860. X        char   location;/* location variable gfr */
  861. X    char   mark;    /* unique mark for nation*/
  862. X        short  capx;    /* capital x coord */
  863. X        short  capy;    /* capital y coord */
  864. X        short  active;    /* activity level of nation, but I am not sure if
  865. X                i have used this variable consistently:
  866. X                 1 if PC NATION, 
  867. X                2+Aggressiveness if NPC, 
  868. X                0 if inactive,
  869. X                999 to represents MONSTER (pirate...)*/
  870. X        short  aplus;    /* attack plus of all soldiers*/
  871. X        short  dplus;    /* attack plus of all soldiers*/
  872. X        short  maxmove;    /* maximum movement of soldiers*/
  873. X        short  repro;    /* reproduction rate of nation*/
  874. X        short  score;    /* score */
  875. X        int    tgold;    /* gold in treasury */
  876. X        int    jewels;    /* raw amount of gold in treasury */
  877. X        int    tmil;    /* total military */
  878. X        int    tciv;    /* total civilians */
  879. X        int    tiron;    /* total real iron in nation*/
  880. X        int    tfood;    /* total food in nation*/
  881. X    long   powers;
  882. X        short  tsctrs;    /* total number sectors */
  883. X        short  tships;    /* number warships */
  884. X    struct army arm[MAXARM];
  885. X    struct navy nvy[MAXNAVY];
  886. X    short  dstatus[MAXNTN+4];    /*diplomatic status*/
  887. X};
  888. X
  889. X#define AXLOC ntn[country].arm[armynum].xloc 
  890. X#define AYLOC ntn[country].arm[armynum].yloc 
  891. X#define AMOVE ntn[country].arm[armynum].smove 
  892. X#define ASOLD ntn[country].arm[armynum].sold 
  893. X#define ASTAT ntn[country].arm[armynum].stat 
  894. X#define NWAR  ntn[country].nvy[nvynum].warships
  895. X#define NMER  ntn[country].nvy[nvynum].merchant
  896. X#define NXLOC ntn[country].nvy[nvynum].xloc 
  897. X#define NYLOC ntn[country].nvy[nvynum].yloc 
  898. X#define NMOVE ntn[country].nvy[nvynum].smove
  899. X
  900. Xextern struct s_sector sct[MAPX][MAPY];
  901. Xextern struct nation ntn[MAXNTN+4];
  902. Xextern short movecost[MAPX][MAPY];
  903. X
  904. X/*Movement costs*/
  905. Xextern char *ele;
  906. Xextern char *veg;
  907. Xextern char *numbers;
  908. Xextern char *races[];
  909. Xextern char *Class[];
  910. Xextern char *vegname[];
  911. Xextern char *diploname[];
  912. Xextern char *soldname[];
  913. X
  914. X#define AORN 0
  915. X#define ARMY 1
  916. X#define NAVY 2
  917. X
  918. X#define XASTAT     1
  919. X#define XAMEN     2
  920. X#define XALOC     4
  921. X#define XNLOC     5 
  922. X#define XNASHP     6 
  923. X#define XECNAME    8 
  924. X#define XECPAS     9 
  925. X#define XECMARK    10 
  926. X#define XSADES     11 
  927. X#define XSACIV     12 
  928. X#define XSIFORT    13 
  929. X#define XNAGOLD    14 
  930. X#define XAMOV     15
  931. X#define XNMOV     16 
  932. X#define XSAOWN     17 
  933. X#define EDADJ    18
  934. X#define XNARGOLD 19
  935. X#define XNAIRON 20
  936. X#define INCAPLUS 22
  937. X#define INCDPLUS 23
  938. X#define CHG_MGK 24
  939. X
  940. X#define CHGMGK fprintf(fexe,"MAGIC \t%d \t%hd \t%d \t%d \t0 \t%s\n",CHG_MGK,country,ntn[country].powers,x,"null")
  941. X#define I_APLUS fprintf(fexe,"INC_APLUS \t%d \t%hd \t0 \t0 \t0 \t%s\n",INCAPLUS,country,"null")
  942. X#define I_DPLUS fprintf(fexe,"INC_DPLUS \t%d \t%hd \t0 \t0 \t0 \t%s\n",INCDPLUS,country,"null")
  943. X#define AADJSTAT fprintf(fexe,"A_STAT \t%d \t%hd \t%d \t%d \t0 \t%s\n",XASTAT,country,armynum,ntn[country].arm[armynum].stat,"null")
  944. X#define AADJMEN  fprintf(fexe,"A_MEN \t%d \t%hd \t%d \t%d \t0 \t%s\n",XAMEN ,country,armynum,ntn[country].arm[armynum].sold,"null")
  945. X#define NADJSHP  fprintf(fexe,"N_ASHP \t%d \t%hd \t%d \t%d \t%d \t%s\n",XNASHP ,country,nvynum,ntn[country].nvy[nvynum].merchant,ntn[country].nvy[nvynum].warships,"null" )
  946. X#define AADJLOC  fprintf(fexe,"A_LOC \t%d \t%hd \t%d \t%d \t%d \t%s\n",XALOC ,country,armynum,ntn[country].arm[armynum].xloc,ntn[country].arm[armynum].yloc,"null")
  947. X#define NADJLOC  fprintf(fexe,"N_LOC \t%d \t%hd \t%d \t%d \t%d \t%s\n",XNLOC ,country,nvynum,ntn[country].nvy[nvynum].xloc,ntn[country].nvy[nvynum].yloc ,"null")
  948. X#define AADJMOV  fprintf(fexe,"A_MOV \t%d \t%hd \t%d \t%d \t0 \t%s\n",XAMOV ,country,armynum,ntn[country].arm[armynum].smove,"null")
  949. X#define NADJMOV  fprintf(fexe,"N_MOV \t%d \t%hd \t%d \t%d \t0 \t%s\n",XNMOV ,country,nvynum,ntn[country].nvy[nvynum].smove,"null")
  950. X#define ECHGNAME fprintf(fexe,"E_CNAME \t%d \t%hd \t0 \t0 \t0 \t%s\n",XECNAME ,country,ntn[country].name)
  951. X#define ECHGPAS  fprintf(fexe,"E_CPAS \t%d \t%hd \t0 \t0 \t0 \t%s\n",XECPAS ,country,crypt(string,SALT))
  952. X#define SADJDES  fprintf(fexe,"S_ADES \t%d \t%hd \t0 \t%d \t%d \t%c\n",XSADES ,country,xcurs+xoffset,ycurs+yoffset,sct[xcurs+xoffset][ycurs+yoffset].designation)
  953. X#define SADJDES2  fprintf(fexe,"S_ADES \t%d \t%hd \t0 \t%d \t%d \t%c\n",XSADES ,country,x,y,sct[x][y].designation)
  954. X#define SADJCIV2  fprintf(fexe,"S_ACIV \t%d \t%hd \t%d \t%d \t%d \t%s\n",XSACIV ,country,sct[i][j].people,i,j,"null")
  955. X#define SADJCIV  fprintf(fexe,"S_ACIV \t%d \t%hd \t%d \t%d \t%d \t%s\n",XSACIV ,country,sct[xcurs+xoffset][ycurs+yoffset].people,xcurs+xoffset,ycurs+yoffset,"null")
  956. X#define INCFORT fprintf(fexe,"SIFORT \t%d \t%hd \t0 \t%d \t%d \t%s\n",XSIFORT ,country,xcurs+xoffset,ycurs+yoffset,"null")
  957. X#define SADJOWN  fprintf(fexe,"S_AOWN \t%d \t%hd \t0 \t%d \t%d \t%s\n",XSAOWN ,country,xcurs+xoffset,ycurs+yoffset,"null")
  958. X#define EADJDIP  fprintf(fexe,"E_ADJ \t%d \t%hd \t%d \t%d \t0 \t%s\n",EDADJ,country,nation,ntn[country].dstatus[nation],"null")
  959. X
  960. X#define    WARRIOR        2
  961. X#define    CAPTAIN        3
  962. X#define    WARLORD        5
  963. X#define    MI_MONST    7
  964. X#define    AV_MONST    11
  965. X#define    MA_MONST    13
  966. X#define    SPY        17
  967. X#define    KNOWALL        19
  968. X#define    DERVISH        23
  969. X/*I CAN CHANGE DESTROYER TO NON PRIME NUMBER IN NEXT GAME*/
  970. X#define    DESTROYER    29
  971. X#define    HIDDEN        31
  972. X#define    THE_VOID    37
  973. X#define    ARCHITECT    41
  974. X#define    VAMPIRE        43
  975. X#define    HEALER        47
  976. X#define MINER        53
  977. X#define URBAN        59
  978. X#define STEEL        61
  979. X#define ARCHER        67
  980. X#define CAVALRY        71
  981. X#define BREEDER        73
  982. X#define MAXPOWER    73    /*maximum power*/
  983. X
  984. X#define NPCPOWERS    9    /*maximum number of powers for NPC*/
  985. X#define PCPOWERS    5    /*maximum number of powers for PC */
  986. X
  987. X/*my first macro: which will return 1 if the nation has that power*/
  988. X#define magic(NATION,POWER)    !(ntn[NATION].powers%(POWER))  
  989. X
  990. X#define beep()        putchar('')
  991. X
  992. X#define FOODTHRESH 3
  993. X#define GOLDTHRESH 10
  994. X#define JEWELTHRESH 10
  995. X    
  996. X#define SALT "aa"
  997. X#define PASSLTH 7
  998. X
  999. X/*intialize subroutine types*/
  1000. Xchar *crypt();
  1001. Xvoid exit();
  1002. Xint rand();
  1003. X
  1004. Xextern char *strcpy(), *strncpy(), *strcat(), *strncat();
  1005. X
  1006. END_OF_header.h
  1007. if test 12852 -ne `wc -c <header.h`; then
  1008.     echo shar: \"header.h\" unpacked with wrong size!
  1009. fi
  1010. # end of overwriting check
  1011. fi
  1012. if test -f io.c -a "${1}" != "-c" ; then 
  1013.   echo shar: Will not over-write existing file \"io.c\"
  1014. else
  1015. echo shar: Extracting \"io.c\" \(10550 characters\)
  1016. sed "s/^X//" >io.c <<'END_OF_io.c'
  1017. X/*io.c*/
  1018. X/*Print and io subroutines for game*/
  1019. X
  1020. X/*conquest is copyrighted 1986 by Ed Barlow.
  1021. X *  I spent a long time writing this code & I hope that you respect this.  
  1022. X *  I give permission to alter the code, but not to copy or redistribute
  1023. X *  it without my explicit permission.  If you alter the code, 
  1024. X *  please document changes and send me a copy, so all can have it.  
  1025. X *  This code, to the best of my knowledge works well,  but it is my first
  1026. X *  'C' program and should be treated as such.  I disclaim any
  1027. X *  responsibility for the codes actions (use at your own risk).  I guess
  1028. X *  I am saying "Happy gaming", and am trying not to get sued in the process.
  1029. X *                                                Ed
  1030. X */
  1031. X
  1032. X/*include files*/
  1033. X#include <ctype.h>
  1034. X#include "header.h"
  1035. X
  1036. X/*Declarations*/
  1037. Xextern struct s_sector sct[MAPX][MAPY];
  1038. Xextern struct nation ntn[NTOTAL];   /* player nation stats */
  1039. X/*is sector occupied by an army?*/
  1040. Xextern short occ[MAPX][MAPY];
  1041. X
  1042. X/*offset of upper left hand corner*/
  1043. Xextern short xoffset;
  1044. Xextern short yoffset;
  1045. X/*current cursor postion (relative to 00 in upper corner)*/
  1046. X/*    position is 2*x,y*/
  1047. Xextern short xcurs;
  1048. Xextern short ycurs;
  1049. X/*redraw map in this turn if redraw is a 1*/
  1050. Xextern short redraw;
  1051. X/*display state*/
  1052. Xextern short hilmode;   /*highlight modes: 0=owned sectors, 1= armies, 2=none*/
  1053. Xextern short dismode;   /*display mode: 1=vegitation, 2=desig, 3=contour*/
  1054. X/*         4=armies/navies, 5=commodities, 6=fertility, 7=movement*/
  1055. X/* nation id of owner*/
  1056. Xextern short country;
  1057. X
  1058. X/*print a sector.altitude map subroutine*/
  1059. Xprintele()
  1060. X{
  1061. X    register int X, Y;
  1062. X    printf("doing print of altitude\n");
  1063. X    for(Y=0;Y<MAPY;Y++) {
  1064. X        for(X=0;X<MAPX;X++) putc(sct[X][Y].altitude,stdout);
  1065. X        putc('\n',stdout);
  1066. X    }
  1067. X}
  1068. X
  1069. Xpr_ntns()
  1070. X{
  1071. X    register int X, Y;
  1072. X    printf("doing print of nations\n");
  1073. X    for(Y=0;Y<MAPY;Y++) {
  1074. X        for(X=0;X<MAPX;X++) {
  1075. X            if(sct[X][Y].owner==0)
  1076. X                putc(sct[X][Y].altitude,stdout);
  1077. X            else putc(ntn[sct[X][Y].owner].mark,stdout);
  1078. X        }
  1079. X        putc('\n',stdout);
  1080. X    }
  1081. X}
  1082. X
  1083. X/*print all data--trashes/creates datafile in the process*/
  1084. Xwritedata()
  1085. X{
  1086. X    int fd;
  1087. X    printf("\ndoing write of data\n");
  1088. X    if((fd = creat(DATAFILE,0666))==-1) {
  1089. X        printf("cant open data.  check permissions\n");
  1090. X        return;
  1091. X    }
  1092. X    write(fd,sct,sizeof(sct));
  1093. X    write(fd,ntn,sizeof(ntn));
  1094. X    close(fd);
  1095. X}
  1096. X
  1097. Xreaddata()
  1098. X{
  1099. X    int fd;
  1100. X    int n_read;
  1101. X    /*read in existing nation army and navy data*/
  1102. X    /*check if file openable*/
  1103. X    printf("reading data file\n");
  1104. X    fd=open(DATAFILE,0);
  1105. X    if((n_read=read(fd,sct,sizeof(sct)))==0) printf("EOF\n");
  1106. X    else if(n_read==-1) printf("error reading sector data (sct)\n");
  1107. X    if(n_read!=sizeof(sct)) {
  1108. X        printf("wrong data format\n");
  1109. X        exit(1);
  1110. X    }
  1111. X    if((n_read=read(fd,ntn,sizeof(ntn)))==0) printf("EOF\n");
  1112. X    else if(n_read==-1) printf("error reading nation data (ntn)\n");
  1113. X    if(n_read!=sizeof(ntn)) {
  1114. X        printf("wrong data format\n");
  1115. X        exit(1);
  1116. X    }
  1117. X    close(fd);
  1118. X}
  1119. X
  1120. X/*print a map subroutine*/
  1121. Xprintveg()
  1122. X{
  1123. X    register int X, Y;
  1124. X    printf("doing print of vegitation\n");
  1125. X    for(Y=0;Y<MAPY;Y++) {
  1126. X        for(X=0;X<MAPX;X++) putc(sct[X][Y].vegitation,stdout);
  1127. X        putc('\n',stdout);
  1128. X    }
  1129. X}
  1130. X
  1131. X/*make a map*/
  1132. Xmakemap()
  1133. X{
  1134. X    register int x,y;
  1135. X    register int i,j;
  1136. X    short armynum,nvynum;
  1137. X
  1138. X    /*can you see all?*/
  1139. X    if((magic(country,KNOWALL)==1)||(country==0)) {
  1140. X        for(x=0;x<(COLS-21)/2;x++) {
  1141. X            for(y=0;y<(LINES-4);y++) {
  1142. X                highlight(x,y);
  1143. X                see(x,y);
  1144. X            }
  1145. X        }
  1146. X        if((hilmode==1)||(hilmode==4)||(hilmode==3)) {
  1147. X            for(armynum=0;armynum<MAXARM;armynum++) 
  1148. X            if((ASOLD>0)&&((AMOVE>0)||(hilmode!=4))){
  1149. X                standout();
  1150. X                see(AXLOC-xoffset,AYLOC-yoffset);
  1151. X            }
  1152. X        }
  1153. X    }
  1154. X    /*see as appropriate?*/
  1155. X    else {
  1156. X        for(x=0;x<(COLS-21)/2;x++) for(y=0;y<(LINES-4);y++) {
  1157. X            if(sct[x+xoffset][y+yoffset].owner==country){
  1158. X                for(i=x-LANDSEE;i<=x+LANDSEE;i++){
  1159. X                    for(j=y-LANDSEE;j<=y+LANDSEE;j++) {
  1160. X                        highlight(i,j);
  1161. X                        see(i,j);
  1162. X                    }
  1163. X                }
  1164. X            }
  1165. X        }
  1166. X        for(nvynum=0;nvynum<MAXNAVY;nvynum++) if(NMER+NWAR>0){
  1167. X            for(i=NXLOC-xoffset-NAVYSEE;i<=NXLOC-xoffset+NAVYSEE;i++) for(j=NYLOC-yoffset-NAVYSEE;j<=NYLOC-yoffset+NAVYSEE;j++){
  1168. X                highlight(i,j);
  1169. X                see(i,j);
  1170. X            }
  1171. X        }
  1172. X        for(armynum=0;armynum<MAXARM;armynum++) if(ASOLD>0){
  1173. X            for(i=AXLOC-xoffset-ARMYSEE;i<=AXLOC-xoffset+ARMYSEE;i++) for(j=AYLOC-yoffset-ARMYSEE;j<=AYLOC-yoffset+ARMYSEE;j++) {
  1174. X                highlight(i,j);
  1175. X                see(i,j);
  1176. X            }
  1177. X        }
  1178. X        /*optimal method of highlighting your armies*/
  1179. X        if((hilmode==3)||(hilmode==4)) {
  1180. X            for(armynum=0;armynum<MAXARM;armynum++) 
  1181. X            if((ASOLD>0)&&((AMOVE>0)||(hilmode==3))){
  1182. X                standout();
  1183. X                see(AXLOC-xoffset,AYLOC-yoffset);
  1184. X            }
  1185. X            for(nvynum=0;nvynum<MAXNAVY;nvynum++) 
  1186. X            if((NWAR+NMER>0)&&((NMOVE>0)||(hilmode==3))){
  1187. X                standout();
  1188. X                see(NXLOC-xoffset,NYLOC-yoffset);
  1189. X            }
  1190. X        }
  1191. X    }
  1192. X    move(ycurs,2*xcurs);
  1193. X}
  1194. X
  1195. Xnewdisplay()
  1196. X{
  1197. X    mvaddstr(LINES-4,0,"viewing options:  (d)esignation, (r)ace, (m)ove cost, (p)eople, (D)efense");
  1198. X    clrtoeol();
  1199. X        mvaddstr(LINES-3,0,"                  (c)ontour, (v)egitation, (i)ron, (n)ation mark, (g)old");
  1200. X    clrtoeol();
  1201. X    mvaddstr(LINES-2,0,"highlight option: (o)wners, (a)rmy, (y)our Army, (M)ove left, (x)=none");
  1202. X    clrtoeol();
  1203. X    standout();
  1204. X    mvaddstr(LINES-1,0,"what display?:");
  1205. X    clrtoeol();
  1206. X    move(LINES-1,16);
  1207. X    standend();
  1208. X    refresh();
  1209. X    redraw=TRUE;
  1210. X    switch(getch()) {
  1211. X    case 'v':    /* vegetation map*/
  1212. X        dismode=1;
  1213. X        break;
  1214. X    case 'd':    /* designations map*/
  1215. X        dismode=2;
  1216. X        break;
  1217. X    case 'c':    /* contour map of world */
  1218. X        dismode=3;
  1219. X        break;
  1220. X    case 'n':    /* nations map*/
  1221. X        dismode=4;
  1222. X        break;
  1223. X    case 'r':    /* race map*/
  1224. X        dismode=5;
  1225. X        break;
  1226. X    case 'm':    /* move cost map*/
  1227. X        dismode=7;
  1228. X        break;
  1229. X    case 'D':
  1230. X        dismode=8;
  1231. X        break;
  1232. X    case 'p':
  1233. X        dismode=9;
  1234. X        break;
  1235. X    case 'g':
  1236. X        dismode=10;
  1237. X        break;
  1238. X    case 'i':
  1239. X        dismode=11;
  1240. X        break;
  1241. X    case 'a':    /* armies hilighted map*/
  1242. X        prep();
  1243. X        hilmode=1;
  1244. X        break;
  1245. X    case 'o':    /* owners hilighted map*/
  1246. X        hilmode=0;
  1247. X        break;
  1248. X    case 'x':    /*no highlighting*/
  1249. X        hilmode=2;
  1250. X        break;
  1251. X    case 'y':    /* your armies hilighted map*/
  1252. X        prep();
  1253. X        hilmode=3;
  1254. X        break;
  1255. X    case 'M':    /* your armies with moves left hilighted map*/
  1256. X        prep();
  1257. X        hilmode=4;
  1258. X        break;
  1259. X    default:
  1260. X        beep();
  1261. X        redraw=FALSE;
  1262. X    }
  1263. X    makebottom();
  1264. X}
  1265. X
  1266. X/*see what is in xy as per display mode*/
  1267. Xsee(x,y)
  1268. X{
  1269. X    int armbonus;
  1270. X    if((x<0)||(y<0)||(x>COLS-21)||(y>=LINES-4)) return;
  1271. X    if(((y+yoffset)<MAPY)&&((x+xoffset)<MAPX)) {
  1272. X
  1273. X        if((dismode>7)&&(country!=sct[x+xoffset][y+yoffset].owner)&&(magic(sct[x+xoffset][y+yoffset].owner,THE_VOID)==1)&&(country!=0)) {
  1274. X            standout();
  1275. X            mvaddch(y,2*x,' ');
  1276. X            standend();
  1277. X        }
  1278. X        else {
  1279. X            switch(dismode){
  1280. X            case 1: /*vegitation*/
  1281. X                mvaddch(y,2*x,sct[x+xoffset][y+yoffset].vegitation);
  1282. X                break;
  1283. X            case 2: /*designation*/
  1284. X                if(sct[x+xoffset][y+yoffset].owner==0){
  1285. X                    if(isdigit(sct[x+xoffset][y+yoffset].vegitation)!=0) mvaddch(y,2*x,sct[x+xoffset][y+yoffset].altitude);
  1286. X                    else mvaddch(y,2*x,sct[x+xoffset][y+yoffset].vegitation);
  1287. X                }
  1288. X                else if((country==0)||(sct[x+xoffset][y+yoffset].owner==country)) mvaddch(y,2*x,sct[x+xoffset][y+yoffset].designation);
  1289. X                else mvaddch(y,2*x,ntn[sct[x+xoffset][y+yoffset].owner].mark);
  1290. X                break;
  1291. X            case 3: /*contour*/
  1292. X                mvaddch(y,2*x,sct[x+xoffset][y+yoffset].altitude);
  1293. X                break;
  1294. X            case 4: /*ownership*/
  1295. X                if(sct[x+xoffset][y+yoffset].owner==0)
  1296. X                    mvaddch(y,2*x,sct[x+xoffset][y+yoffset].altitude);
  1297. X                else mvaddch(y,2*x,ntn[sct[x+xoffset][y+yoffset].owner].mark);
  1298. X                break;
  1299. X            case 5: /*race*/
  1300. X                if(sct[x+xoffset][y+yoffset].owner==0)
  1301. X                    mvaddch(y,2*x,sct[x+xoffset][y+yoffset].altitude);
  1302. X                else mvaddch(y,2*x,ntn[sct[x+xoffset][y+yoffset].owner].race);
  1303. X                break;
  1304. X            case 7:    /*movement cost map*/
  1305. X                if(movecost[x+xoffset][y+yoffset]>=0) mvprintw(y,2*x,"%d",movecost[x+xoffset][y+yoffset]);
  1306. X                else if(sct[x+xoffset][y+yoffset].altitude==WATER)
  1307. X                    mvaddch(y,2*x,'~');
  1308. X                else
  1309. X                    mvaddch(y,2*x,'X');
  1310. X                break;
  1311. X            case 8:   /*Defence*/
  1312. X                if (sct[x+xoffset][y+yoffset].altitude==WATER)
  1313. X                    mvaddch(y,2*x,'~');
  1314. X                else if (movecost[x+xoffset][y+yoffset]<0)
  1315. X                    mvaddch(y,2*x,'*');
  1316. X                else {
  1317. X
  1318. X                    /*Racial combat bonus due to terrain (the faster you move the better)*/
  1319. X                    armbonus=0;
  1320. X                    armbonus+=5*(9-movecost[x+xoffset][y+yoffset]);
  1321. X
  1322. X                    if(sct[x+xoffset][y+yoffset].altitude==MOUNTAIN) armbonus+=40;
  1323. X                    else if(sct[x+xoffset][y+yoffset].altitude==HILL) armbonus+=20;
  1324. X
  1325. X                    if(sct[x+xoffset][y+yoffset].vegitation==JUNGLE)
  1326. X                        armbonus+=30;
  1327. X                    else if(sct[x+xoffset][y+yoffset].vegitation==FORREST)
  1328. X                        armbonus+=20;
  1329. X                    else if(sct[x+xoffset][y+yoffset].vegitation==WOOD)
  1330. X                        armbonus+=10;
  1331. X
  1332. X                    if((sct[x+xoffset][y+yoffset].designation==DCASTLE)||(sct[x+xoffset][y+yoffset].designation==DCITY)||(sct[x+xoffset][y+yoffset].designation==DCAPITOL))
  1333. X                        armbonus+=8*sct[x+xoffset][y+yoffset].fortress;
  1334. X
  1335. X                    mvprintw(y,2*x,"%d",armbonus/20);
  1336. X                }
  1337. X                break;
  1338. X            case 9:   /*People*/
  1339. X                if (sct[x+xoffset][y+yoffset].altitude==WATER)
  1340. X                    mvaddch(y,2*x,'~');
  1341. X                else if (sct[x+xoffset][y+yoffset].people>=1000)
  1342. X                    mvaddch(y,2*x,'+');
  1343. X                else if (sct[x+xoffset][y+yoffset].people>=450)
  1344. X                    mvaddch(y,2*x,'>');
  1345. X                else if (sct[x+xoffset][y+yoffset].people==0)
  1346. X                    mvaddch(y,2*x,'0');
  1347. X                else
  1348. X                    mvprintw(y,2*x,"%d",1+sct[x+xoffset][y+yoffset].people/50);
  1349. X                break;
  1350. X            case 10:  /*Gold*/
  1351. X                if (sct[x+xoffset][y+yoffset].altitude==WATER)
  1352. X                    mvaddch(y,2*x,'~');
  1353. X                else if(isdigit(sct[x+xoffset][y+yoffset].vegitation)==0) 
  1354. X                    mvaddch(y,2*x,'X');
  1355. X                else if((sct[x+xoffset][y+yoffset].owner!=0)&&(sct[x+xoffset][y+yoffset].owner!=country))
  1356. X                    mvaddch(y,2*x,'?');
  1357. X                else if(sct[x+xoffset][y+yoffset].gold>=10)
  1358. X                    mvaddch(y,2*x,'+');
  1359. X                else
  1360. X                    mvprintw(y,2*x,"%d",sct[x+xoffset][y+yoffset].gold);
  1361. X                break;
  1362. X            case 11:  /*Iron*/
  1363. X                if (sct[x+xoffset][y+yoffset].altitude==WATER)
  1364. X                    mvaddch(y,2*x,'~');
  1365. X                else if(isdigit(sct[x+xoffset][y+yoffset].vegitation)==0) 
  1366. X                    mvaddch(y,2*x,'X');
  1367. X                else if((sct[x+xoffset][y+yoffset].owner!=0)&&(sct[x+xoffset][y+yoffset].owner!=country))
  1368. X                    mvaddch(y,2*x,'?');
  1369. X                else if (sct[x+xoffset][y+yoffset].iron>=10)
  1370. X                    mvaddch(y,2*x,'+');
  1371. X                else
  1372. X                    mvprintw(y,2*x,"%d",sct[x+xoffset][y+yoffset].iron);
  1373. X                break;
  1374. X            default:
  1375. X                break;
  1376. X            }
  1377. X        }
  1378. X    }
  1379. X    else mvaddch(y,2*x,' ');
  1380. X    standend();
  1381. X}
  1382. X
  1383. X/*highlight what is in xy as per highlight mode*/
  1384. Xhighlight(x,y)
  1385. X{
  1386. X    if((x<0)||(y<0)||(x>COLS-21)||(y>=LINES-4)) return;
  1387. X    if(((y+yoffset)<MAPY)&&((x+xoffset)<MAPX)) {
  1388. X        switch(hilmode){
  1389. X        case 0: /*ownership*/
  1390. X            if(country==0) {
  1391. X                if(sct[x+xoffset][y+yoffset].owner>0)
  1392. X                    standout();
  1393. X            }
  1394. X            else if(sct[x+xoffset][y+yoffset].owner==country)
  1395. X                standout();
  1396. X            break;
  1397. X        case 1: /*army map*/
  1398. X            if(occ[x+xoffset][y+yoffset]!=0) standout();
  1399. X            break;
  1400. X        default:
  1401. X            break;
  1402. X        }
  1403. X    }
  1404. X}
  1405. END_OF_io.c
  1406. if test 10550 -ne `wc -c <io.c`; then
  1407.     echo shar: \"io.c\" unpacked with wrong size!
  1408. fi
  1409. # end of overwriting check
  1410. fi
  1411. echo shar: End of archive 5 \(of 5\).
  1412. cp /dev/null ark5isdone
  1413. MISSING=""
  1414. for I in 1 2 3 4 5 ; do
  1415.     if test ! -f ark${I}isdone ; then
  1416.     MISSING="${MISSING} ${I}"
  1417.     fi
  1418. done
  1419. if test "${MISSING}" = "" ; then
  1420.     echo You have unpacked all 5 archives.
  1421.     rm -f ark[1-9]isdone
  1422. else
  1423.     echo You still need to unpack the following archives:
  1424.     echo "        " ${MISSING}
  1425. fi
  1426. ##  End of shell archive.
  1427. exit 0
  1428.